﻿namespace MLSharp.Classification
{
	/// <summary>
	/// Stores the result of a classification.
	/// </summary>
	public class ClassificationResult
	{
		#region Public Properties

		/// <summary>
		/// Gets the predicted class.
		/// </summary>
		//TODO: Consider replacing this with a double?  That would make it harder to support string
		//class values...
		public string PredictedClass { get; set; }

		/// <summary>
		/// The actual class of the object that was evaluated.
		/// </summary>
		public string ActualClass { get; set; }

		/// <summary>
		/// Gets the confidence in the prediction in the [0.0,1.0] range.
		/// </summary>
		public double Confidence { get; set; }

		/// <summary>
		/// Gets the ID of the instance that was classified, if specified.
		/// </summary>
		public string ID { get; set; }

		/// <summary>
		/// The explanation for the classification.  Not all classifiers use this field.
		/// </summary>
		public string Explanation { get; set; }

		#endregion

		#region Public Constructors

		/// <summary>
		/// Creates a classification result.
		/// </summary>
		/// <param name="predictedClass">The predicted class.</param>
		/// <param name="actualClass">The actual class.</param>
		public ClassificationResult(string predictedClass, string actualClass)
		{
			PredictedClass = predictedClass;
			ActualClass = actualClass;
		}

		#endregion

		#region Overrides

		/// <summary>
		/// Formats the result into a readable string.
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			return string.Format("ID {0}, PredictedClass - {1} [{2}], ActualClass - {3}, Explanation: {4}", ID, PredictedClass, Confidence, ActualClass, Explanation ?? "n/a");
		}

		#endregion
	}
}
